<?php
/**
 * 后台公共配置文件
 * @author chenhao
 * @copyright 成都四方客信息技术有限公司
 * @link http://www.sifangke.cn/
 * @since Thu Nov 19 14:14:31 CST 2009
 */
 
if (!defined('IN_SYS')) {
	die('No admittance');
}

/********************************/
// --取得系统后台相关的路径
/********************************/
define('ADMIN_PATH',str_replace('includes/init.php','',str_replace('\\','/',__FILE__)));  //后台系统所在路径
define('ROOT_PATH',preg_replace('/\/[a-z0-9_]+\/$/U','',ADMIN_PATH).'/'); // 系统所在的根目录
define('ADMIN_DIR',substr(ADMIN_PATH,strlen(ROOT_PATH)));
define('PHP_SELF', isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']); //当前文件所在路径

/********************************/
// --包含系统所需的公共文件
/********************************/
require(ROOT_PATH . 'data/config.inc.php');
if (isset($languages) && in_array($languages,array('CN','EN','TW'))) {
	require(ROOT_PATH . 'languages/'.$languages.'_lang_inc.php');
} else {
	die('Set languager error!');
}
require(ROOT_PATH . 'includes/smarty/Smarty.class.php');
require(ROOT_PATH . 'includes/cls_mysql.php');
require(ROOT_PATH . 'includes/cls_system.php');
require(ROOT_PATH . 'includes/lib_common.php');
require(ADMIN_PATH . 'includes/lib_private.php');

/********************************/
// --时区设置
/********************************/
if (PHP_VERSION > 5.1 && !empty($timezone)) {
	date_default_timezone_set($timezone);
}

/********************************/
// --初始化smarty引擎
/********************************/
$smarty = new Smarty();
$smarty->template_dir = ADMIN_PATH . 'templates/';
$smarty->compile_dir = ROOT_PATH . 'data/themes/templates_c/';
$smarty->cache_dir = ROOT_PATH . 'data/themes/cache/';
if ($is_caching) {
	$smarty->caching = true;
	$smarty->cache_lifetime = 60;
}

/********************************/
// --初始化数据库操作类
/********************************/
$sys = new cls_system($dbname, $prefix);
$db = new cls_mysql($host, $user, $pw, $dbname, $port, $charset, $pconnect);

/********************************/
// --初始后台系统公共信息
/********************************/
$_CH = sys_config();
define('SITE_NAME',empty($_CH['site_name']) ? $_LANG['SITE_NAME'] : $_CH['site_name']);
$smarty->assign(admin_dir, ADMIN_DIR);
$smarty->assign(charset, $charset);
$smarty->assign(site_name, SITE_NAME);
